﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;

namespace XamlaApp.Converters
{
    public class TextAlignmentToString : IValueConverter
    {

        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var tr = (TextAlignment)value;
            switch (tr)
            {
                case TextAlignment.Left:
                    return 0;
                case TextAlignment.Center:
                    return 1;
                case TextAlignment.Right:
                    return 2;
            }
            return 0;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var c = (int)value;
            switch (c)
            {
                case 0:
                    return TextAlignment.Left;
                case 1:
                    return TextAlignment.Center;
                case 2:
                    return TextAlignment.Right;
            }

            return TextAlignment.Left;
        }

        #endregion
    }
}
